<script language="javascript">
$(function(){
	$('form').form({ 
		success:function(data){
			var data = runJson(data);
			if(data.status == 0){
				alertText(data.info, 'error');
			}else{
				alertText(data.info, 'success', '{:U('User/index')}');
			}
		}   
	});
		
});
function selectCustom(){
	$('#window_custom').dialog({
		title:'选择客户',
		href: '{:U("User/custom")}',
		width: 650,
		height: 520,
		modal:true,
		buttons:[{
			text:'确定',
			iconCls:'icon-ok2',
			handler:function(){
				var row = $('#custom_datagrid').datagrid('getSelected');
				if(!row){ alert('请选择用户组！'); return fales; }
				$('#custom_id').val(row.custom_id);
				$('#custom_id_text').html(row.name);
				$('#window_custom').dialog('close');
			}
		},{
			text:'取消',
			handler:function(){
				$('#window_custom').dialog('close');
			}
		}]
	});
}
</script>
<style type="text/css">
.window .window-body { margin:0px; padding:5px; width:640px; overflow:hidden; }
.nt { color:#F90; padding-left:10px; }
</style>
<div class="wrapper clear">
	<div class="main">
    	<div class="toolbar">
			<a href="{:U('User/index')}" class="btn">用户列表</a>
		</div>
		<div class="search">
            <div class="searchbox">
        		<h3><eq name='ACTION_NAME' value='edit'>编辑用户<else/>新增用户</eq></h3>
                <form action="<eq name='ACTION_NAME' value='edit'>{:U('User/update')}<else />{:U('User/insert')}</eq>&ajax=true" method="post">
                  <table class="tableform" cellpadding="0" cellspacing="0" style="width:900px;">
                    <tr>
                      <th>用户名称：</th>
                      <td><input type="text" value="{$vo.username}" id="username" name="username" style="width:200px;" class="easyui-validatebox input text" required="true" validType="length[2,20]" <eq name='ACTION_NAME' value='edit'>readonly="readonly"</eq> />
                      <eq name='ACTION_NAME' value='add'><span class="nt">*  新用户默认密码为：<?php echo C('DEFAULT_PASSWORD');?></span></eq>
                      </td>
                    </tr>
                    <eq name='ACTION_NAME' value='edit'>
                    <tr>
                      <th>修改密码：</th>
                      <td>
                      <input type="input" name="password" id="password" value="" class="input text" style="width:200px;" /><span class="nt">*  密码不修改请留空。</span>
                      </td>
                    </tr>
                    </eq>
                    <tr>
                      <th>用户状态：</th>
                      <td><select name="status">
                          <option value="1" <eq name="vo['status']" value="1">selected</eq>>启用
                          </option>
                          <option value="0" <eq name="vo['status']" value="0">selected</eq> >禁用
                          </option>
                        </select>
                        <span class="nt">*</span>
                        </td>
                    </tr>
                    <tr>
                      <th>角色：</th>
                      <td><select name="role_id" id="role_id">
                          <option value="0">请选择</option>
                          <volist name="roleList" id="type"> <option value="{$type.id}" <if condition="$type['id'] eq $vo['role_id']">selected</if>>{$type.name}</option>
                          </volist>
                        </select>
                        <span class="nt">*</span>
                        </td>
                    </tr>
                    <tr>
                    <th>所属用户组：</th>
                    <td>
                    <select name="custom_id" id="custom_id">
                          <option value="0">请选择</option>
                   <volist name="custom_list" id="type"> <option value="{$type.id}" <if condition="$type['id'] eq $vo['custom_id']">selected</if>>{$type.name}</option>
                      </volist>
                     </select>
                     <span class="nt">*</span>
                    </td>
                    </tr>
                    <tr>
                      <th>手机号码：</th>
                      <td><input type="text" value="{$vo.telephone}" id="telephone" name="telephone" style="width:200px;" class="input text" /></td>
                    </tr>
                    <tr>
                      <th>电子邮箱：</th>
                      <td><input type="text" value="{$vo.email}" id="email" name="email" style="width:200px;" class="input text" /></td>
                    </tr>
                    <tr>
                      <th>排序：</th>
                      <td><input type="text" class="input text" name="sort" id="sort" value="{$vo.sort}" style="width:100px;" /></td>
                    </tr>
                    <tr>
                      <th>备注：</th>
                      <td><textarea class="input textarea" name="remark" id="remark" style="width:300px; height:100px;">{$vo.remark}</textarea></td>
                    </tr>
                  </table>
                  <eq name='ACTION_NAME' value='edit'>
                          <input type="hidden" name="id" value="{$vo.id}" />
                        </eq>
                  <!--添加-->
                  <table align="center">
                    <tr>
                      <td align="center"><input class="submit" type="submit" value="保存" id="submits" onclick="return $('form').form('validate')" />
                        <input class="cancel" type="reset" value="取消" /></td>
                    </tr>
                  </table>
                  <!--end添加-->  
                </form>
            </div>
		</div>
	</div>
</div>
<div id="window_custom"></div>